//
//  HMOrderTableViewCell.m
//  G05爱鲜蜂
//
//  Created by 小灰灰 on 16/10/20.
//  Copyright © 2016年 何源. All rights reserved.
//

#import "HMOrderTableViewCell.h"
#import "HMOrderModel.h"
#import "HMOrderGoods.h"
#import "HMOrderTimeLine.h"
@interface HMOrderTableViewCell()
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *stateLabel;
@property (weak, nonatomic) IBOutlet UIImageView *image1;
@property (weak, nonatomic) IBOutlet UIImageView *image2;
@property (weak, nonatomic) IBOutlet UIImageView *image3;
@property (weak, nonatomic) IBOutlet UIImageView *image4;
@property (weak, nonatomic) IBOutlet UIImageView *moreImage;
@property (weak, nonatomic) IBOutlet UILabel *goodsCountAndMoney;

@end
@implementation HMOrderTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    

}
-(void)setModel:(HMOrderModel *)model{
    _model = model;
    self.timeLabel.text = model.lastUpdateTime;
    self.goodsCountAndMoney.text = [NSString stringWithFormat:@"共%ld件商品    实付:$%@",model.order_goods.count,model.real_amount];
    [self.moreImage setHidden:model.order_goods.count < 5];
    [self.image4 setHidden: model.order_goods.count < 4];
    [self.image3 setHidden: model.order_goods.count < 3];
    
    HMOrderGoods *goods;
    for(int i = 0;i < model.order_goods.count;i++){
        goods = model.order_goods[i];
        
        if(i == 0){
 
            [self.image1 sd_setImageWithURL:[NSURL URLWithString:goods.img]];
            
        }
        if(i == 1){
            [self.image2 sd_setImageWithURL:[NSURL URLWithString: goods.img]];
        }
        if(i == 2){
            [self.image3 sd_setImageWithURL:[NSURL URLWithString:goods.img]];
        }
        if(i == 3){
            [self.image4 sd_setImageWithURL:[NSURL URLWithString:goods.img]];
        }
    }

}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
